﻿using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour 
{
    public enum CameraType 
    {
      LockUnit,
    }
    public CameraType mCameraType;
    Unit mLockUnit;
    Vector3 OffsetPos;
    public virtual void OnLoad() 
    { 
    }
    public void LockToUnit(Unit mUnit,Vector3 offsetPos) 
    {
        this.mLockUnit = mUnit;
        this.mCameraType = CameraType.LockUnit;
        this.OffsetPos = offsetPos;
    }

    public void Update() 
    {
        if (mCameraType == CameraType.LockUnit && mLockUnit != null) 
        {
            transform.localPosition = new Vector3(mLockUnit.transform.localPosition.x + OffsetPos.x, 
                mLockUnit.transform.localPosition.y + OffsetPos.y,
                mLockUnit.transform.localPosition.z + OffsetPos.z);
        }
    }
}
